package cn.lyjuan.payment.third.base.common.enums.impl;

import cn.lyjuan.payment.third.base.common.enums.ICodeEnum;
import cn.lyjuan.payment.third.base.pay.enums.SimpleStatusEnum;

public enum TransferStatusEnum implements ICodeEnum {
    /**
     * 未转账
     */
    UN_TRANSFER(0, SimpleStatusEnum.UNKNOWN)
    /**
     * 转账成功
     */
    , SUCC(1, SimpleStatusEnum.SUCC)
    /**
     * 转账失败
     */
    , FAIL(2, SimpleStatusEnum.FAIL);

    private Integer code;

    private SimpleStatusEnum simpleStatusEnum;

    public Integer getCode() {
        return code;
    }

    public SimpleStatusEnum getSimpleStatusEnum() {
        return simpleStatusEnum;
    }

    TransferStatusEnum(Integer code, SimpleStatusEnum simpleStatusEnum) {
        this.code = code;
        this.simpleStatusEnum = simpleStatusEnum;
    }

    public static TransferStatusEnum from(SimpleStatusEnum simpleStatusEnum) {
        if (null == simpleStatusEnum)
            throw new NullPointerException("simple status enum cannot be null");

        TransferStatusEnum[] es = TransferStatusEnum.class.getEnumConstants();
        for (TransferStatusEnum e : es) {
            if (e.simpleStatusEnum == simpleStatusEnum)
                return e;
        }
        throw new RuntimeException("unsupported simple status enum: " + simpleStatusEnum);
    }
}
